﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
	/// <summary>
	/// 类T_SCHOOL。
	/// </summary>
	[Serializable]
	public partial class T_SCHOOL
	{
		public T_SCHOOL()
		{}
		#region Model
		private string _schoolid;
		private string _schoolshortname;
		private string _schoolname;
		private string _schoolphone;
		private string _schooladdr;
		private string _schoolurl;
		private string _schoolno;
		/// <summary>
		/// 流水号
		/// </summary>
		public string SCHOOLID
		{
			set{ _schoolid=value;}
			get{return _schoolid;}
		}
		/// <summary>
		/// 学校简称
		/// </summary>
		public string SCHOOLSHORTNAME
		{
			set{ _schoolshortname=value;}
			get{return _schoolshortname;}
		}
		/// <summary>
		/// 学校名称
		/// </summary>
		public string SCHOOLNAME
		{
			set{ _schoolname=value;}
			get{return _schoolname;}
		}
		/// <summary>
		/// 联系电话
		/// </summary>
		public string SCHOOLPHONE
		{
			set{ _schoolphone=value;}
			get{return _schoolphone;}
		}
		/// <summary>
		/// 学校地址
		/// </summary>
		public string SCHOOLADDR
		{
			set{ _schooladdr=value;}
			get{return _schooladdr;}
		}
		/// <summary>
		/// 学校网址
		/// </summary>
		public string SCHOOLURL
		{
			set{ _schoolurl=value;}
			get{return _schoolurl;}
		}
		/// <summary>
		/// 学校编号
		/// </summary>
		public string SCHOOLNO
		{
			set{ _schoolno=value;}
			get{return _schoolno;}
		}
		#endregion Model


		#region  Method

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public T_SCHOOL(string SCHOOLID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select SCHOOLID,SCHOOLSHORTNAME,SCHOOLNAME,SCHOOLPHONE,SCHOOLADDR,SCHOOLURL,SCHOOLNO ");
			strSql.Append(" FROM T_SCHOOL ");
			strSql.Append(" where SCHOOLID=:SCHOOLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCHOOLID", OracleType.VarChar,50)};
			parameters[0].Value = SCHOOLID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["SCHOOLID"]!=null && ds.Tables[0].Rows[0]["SCHOOLID"].ToString()!="")
				{
					this.SCHOOLID=ds.Tables[0].Rows[0]["SCHOOLID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLSHORTNAME"]!=null && ds.Tables[0].Rows[0]["SCHOOLSHORTNAME"].ToString()!="")
				{
					this.SCHOOLSHORTNAME=ds.Tables[0].Rows[0]["SCHOOLSHORTNAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLNAME"]!=null && ds.Tables[0].Rows[0]["SCHOOLNAME"].ToString()!="")
				{
					this.SCHOOLNAME=ds.Tables[0].Rows[0]["SCHOOLNAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLPHONE"]!=null && ds.Tables[0].Rows[0]["SCHOOLPHONE"].ToString()!="")
				{
					this.SCHOOLPHONE=ds.Tables[0].Rows[0]["SCHOOLPHONE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLADDR"]!=null && ds.Tables[0].Rows[0]["SCHOOLADDR"].ToString()!="")
				{
					this.SCHOOLADDR=ds.Tables[0].Rows[0]["SCHOOLADDR"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLURL"]!=null && ds.Tables[0].Rows[0]["SCHOOLURL"].ToString()!="")
				{
					this.SCHOOLURL=ds.Tables[0].Rows[0]["SCHOOLURL"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLNO"]!=null && ds.Tables[0].Rows[0]["SCHOOLNO"].ToString()!="")
				{
					this.SCHOOLNO=ds.Tables[0].Rows[0]["SCHOOLNO"].ToString();
				}
			}
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string SCHOOLID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from T_SCHOOL");
			strSql.Append(" where SCHOOLID=:SCHOOLID ");

			OracleParameter[] parameters = {
					new OracleParameter(":SCHOOLID", OracleType.VarChar,50)};
			parameters[0].Value = SCHOOLID;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_SCHOOL (");
			strSql.Append("SCHOOLID,SCHOOLSHORTNAME,SCHOOLNAME,SCHOOLPHONE,SCHOOLADDR,SCHOOLURL,SCHOOLNO)");
			strSql.Append(" values (");
			strSql.Append(":SCHOOLID,:SCHOOLSHORTNAME,:SCHOOLNAME,:SCHOOLPHONE,:SCHOOLADDR,:SCHOOLURL,:SCHOOLNO)");
			OracleParameter[] parameters = {
					new OracleParameter(":SCHOOLID", OracleType.VarChar,10),
					new OracleParameter(":SCHOOLSHORTNAME", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLNAME", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLPHONE", OracleType.VarChar,30),
					new OracleParameter(":SCHOOLADDR", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLURL", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLNO", OracleType.VarChar,60)};
			parameters[0].Value = SCHOOLID;
			parameters[1].Value = SCHOOLSHORTNAME;
			parameters[2].Value = SCHOOLNAME;
			parameters[3].Value = SCHOOLPHONE;
			parameters[4].Value = SCHOOLADDR;
			parameters[5].Value = SCHOOLURL;
			parameters[6].Value = SCHOOLNO;

			DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_SCHOOL set ");
			strSql.Append("SCHOOLSHORTNAME=:SCHOOLSHORTNAME,");
			strSql.Append("SCHOOLNAME=:SCHOOLNAME,");
			strSql.Append("SCHOOLPHONE=:SCHOOLPHONE,");
			strSql.Append("SCHOOLADDR=:SCHOOLADDR,");
			strSql.Append("SCHOOLURL=:SCHOOLURL,");
			strSql.Append("SCHOOLNO=:SCHOOLNO");
			strSql.Append(" where SCHOOLID=:SCHOOLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCHOOLSHORTNAME", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLNAME", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLPHONE", OracleType.VarChar,30),
					new OracleParameter(":SCHOOLADDR", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLURL", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLNO", OracleType.VarChar,60),
					new OracleParameter(":SCHOOLID", OracleType.VarChar,10)};
			parameters[0].Value = SCHOOLSHORTNAME;
			parameters[1].Value = SCHOOLNAME;
			parameters[2].Value = SCHOOLPHONE;
			parameters[3].Value = SCHOOLADDR;
			parameters[4].Value = SCHOOLURL;
			parameters[5].Value = SCHOOLNO;
			parameters[6].Value = SCHOOLID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string SCHOOLID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_SCHOOL ");
			strSql.Append(" where SCHOOLID=:SCHOOLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCHOOLID", OracleType.VarChar,50)};
			parameters[0].Value = SCHOOLID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public void GetModel(string sSCHOOLID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select SCHOOLID,SCHOOLSHORTNAME,SCHOOLNAME,SCHOOLPHONE,SCHOOLADDR,SCHOOLURL,SCHOOLNO ");
			strSql.Append(" FROM T_SCHOOL ");
			strSql.Append(" where SCHOOLID=:SCHOOLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCHOOLID", OracleType.VarChar,50)};
			parameters[0].Value = sSCHOOLID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["SCHOOLID"]!=null && ds.Tables[0].Rows[0]["SCHOOLID"].ToString()!="")
				{
					this.SCHOOLID=ds.Tables[0].Rows[0]["SCHOOLID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLSHORTNAME"]!=null && ds.Tables[0].Rows[0]["SCHOOLSHORTNAME"].ToString()!="")
				{
					this.SCHOOLSHORTNAME=ds.Tables[0].Rows[0]["SCHOOLSHORTNAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLNAME"]!=null && ds.Tables[0].Rows[0]["SCHOOLNAME"].ToString()!="")
				{
					this.SCHOOLNAME=ds.Tables[0].Rows[0]["SCHOOLNAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLPHONE"]!=null && ds.Tables[0].Rows[0]["SCHOOLPHONE"].ToString()!="")
				{
					this.SCHOOLPHONE=ds.Tables[0].Rows[0]["SCHOOLPHONE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLADDR"]!=null && ds.Tables[0].Rows[0]["SCHOOLADDR"].ToString()!="")
				{
					this.SCHOOLADDR=ds.Tables[0].Rows[0]["SCHOOLADDR"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLURL"]!=null && ds.Tables[0].Rows[0]["SCHOOLURL"].ToString()!="")
				{
					this.SCHOOLURL=ds.Tables[0].Rows[0]["SCHOOLURL"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLNO"]!=null && ds.Tables[0].Rows[0]["SCHOOLNO"].ToString()!="")
				{
					this.SCHOOLNO=ds.Tables[0].Rows[0]["SCHOOLNO"].ToString();
				}
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM T_SCHOOL ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		#endregion  Method
	}
}

